Workload Analysis
Analyze team member workload to identify capacity issues and provide proactive recommendations for balanced task distribution.
Instructions
Comprehensive workload analysis with proactive insights and predictive recommendations
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| assignee | Yes | Person to analyze (e.g., "John", "Jane") |
Implementation Reference
- The MCP tool handler function that executes the workload analysis logic by instantiating WorkloadAnalysisProcessor and returning structured JSON response.handler: async ({ assignee }: { assignee: string }) => { try { const processor = new WorkloadAnalysisProcessor(process.env.MCP_DEBUG_MODE === 'true'); const analysis = await processor.analyzeWorkload(assignee); // SAFETY: Ensure analysis is valid if (!analysis) { throw new Error('Workload analysis returned null or undefined'); } return { content: [ { type: 'text', text: JSON.stringify( { assignee: analysis.assignee || assignee, summary: `${analysis.assignee || assignee}: ${analysis.totalTasks || 0} tasks, ${analysis.workloadScore || 0}/100 score, ${analysis.efficiency || 0}% efficiency`, workload_score: analysis.workloadScore || 0, efficiency: analysis.efficiency || 0, capacity_utilization: analysis.capacityUtilization || 0, velocity_trend: analysis.velocityTrend || 'STABLE', status_breakdown: analysis.statusBreakdown || { TODO: 0, IN_PROGRESS: 0, COMPLETED: 0, BLOCKED: 0, }, overdue_tasks: analysis.overdueTasks || 0, risk_factors: analysis.riskFactors || [], insights: analysis.insights || [], recommendations: analysis.recommendations || [], prediction: analysis.prediction || null, team_context: analysis.teamContext || null, requires_attention: (analysis.workloadScore || 0) > 80 || (analysis.riskFactors || []).length > 1, }, null, 2, ), }, ], }; } catch (error) { console.error(`[WorkloadAnalysis] Handler failed:`, error); return { content: [ { type: 'text', text: JSON.stringify( { assignee, success: false, error: (error as Error).message, summary: `Failed to analyze workload for ${assignee}`, insights: ['Workload analysis unavailable'], recommendations: ['Check system connectivity and try again'], }, null, 2, ), }, ], }; } },
- Zod schema defining the input parameters for the 'Workload Analysis' tool (assignee string).parameters: z.object({ assignee: z .string() .min(1, 'Assignee name is required') .max(100, 'Assignee name too long') .describe('Person name to analyze workload for (e.g., "John", "Jane")'),
- src/mcp/tools/index.ts:16-16 (registration)Registration of the 'Workload Analysis' tool (workloadAnalysisTool) in the mcpTools array used by the MCP server.export const mcpTools = [naturalLanguageQueryTool, workloadAnalysisTool, riskAssessmentTool];
- Core analyzeWorkload method in WorkloadAnalysisProcessor class that orchestrates the full workload analysis pipeline including caching, enhancement, prediction, and team context.async analyzeWorkload(assignee: string): Promise<EnhancedWorkloadAnalysis> { const startTime = Date.now(); try { this.debug(`Analyzing workload for: ${assignee}`); // CACHE: Check for recent analysis const cacheKey = `workload:analysis:${assignee.toLowerCase()}`; let cachedAnalysis = await CacheService.get<EnhancedWorkloadAnalysis>(cacheKey); if (cachedAnalysis) { this.debug(`Retrieved cached analysis for ${assignee}`); return cachedAnalysis; } // Stage 1: Get base workload analysis const baseAnalysis = await this.apiClient.getWorkloadAnalysis(assignee); // Stage 2: Enhance with proactive insights const enhancedAnalysis = await this.enhanceWorkloadAnalysis(baseAnalysis); // Stage 3: Add predictive modeling enhancedAnalysis.prediction = await this.generateWorkloadPrediction(enhancedAnalysis); // Stage 4: Add team context enhancedAnalysis.teamContext = await this.generateTeamContext(enhancedAnalysis); // CACHE: Store enhanced analysis await CacheService.set(cacheKey, enhancedAnalysis, this.ANALYSIS_CACHE_TTL); const processingTime = Date.now() - startTime; this.debug(`Workload analysis completed for ${assignee} in ${processingTime}ms`); return enhancedAnalysis; } catch (error) { this.debug(`Workload analysis failed for ${assignee}: ${error}`); throw error; } }
- src/mcp/server.ts:90-102 (schema)Simplified input schema returned by MCP server for tool listing (ListToolsRequest).case 'Workload Analysis': return { type: 'object', properties: { assignee: { type: 'string', description: 'Person to analyze (e.g., "John", "Jane")', minLength: 1, maxLength: 100, }, }, required: ['assignee'], };